/**
 * TecAdmin TecAdmin.java
 */

package CCT220_Trabalho05_13106_Q1.model;

/**
 * </br>******************************
 * </br>Project: CCT220
 * </br>Package: CCT220_Trabalho05_13106.model
 * </br>Class: TecAdmin
 * </br>Last Change: 11/10/2011 21:54:11 by marcel
 * </br>Description: Entity: Class TecAdmin extends Funcionario
 * </br>******************************</br>
 * 
 * @author marcel
 * @author 13106
 * 
 */
public class TecAdmin extends Funcionario {
	/**
	 * String
	 */
	private final String funcao;
	/**
	 * double
	 */
	private final double salarioMensal;


	/**
	 * </br>******************************
	 * </br>Constructor for
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: TecAdmin
	 * </br>LastChange: 11/10/2011 21:55:04 by marcel
	 * </br>******************************</br>
	 * 
	 * @param codigo
	 * @param nome
	 * @param funcao
	 * @param salarioMensal
	 */
	public TecAdmin(int codigo, String nome, String funcao, double salarioMensal) {

		super(codigo, nome);
		this.funcao = funcao;
		this.salarioMensal = salarioMensal;
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see CCT220_Trabalho05_13106.model.Funcionario#calculaBonus(int, int)
	 */
	@Override
	public double calculaBonus(int pMes, int pAno) {

		double salLiq = calculaSalario(pMes, pAno);
		double nroAtrasos = 0;

		for (int i = 0; i < this.getPontoMensal().size(); i++) {
			if (this.getPontoMensal().get(i).getMes() == pMes
			        && this.getPontoMensal().get(i).getAno() == pAno) {
				nroAtrasos = this.getPontoMensal().get(i).getNroAtrasos();
			}
		}

		return ((8 - nroAtrasos) > 0 ? (salLiq * (8 - nroAtrasos)) : (0));
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see CCT220_Trabalho05_13106.model.Funcionario#calculaSalario(int, int)
	 */
	@Override
	public double calculaSalario(int pMes, int pAno) {

		double nroFaltas = 0;

		for (int i = 0; i < this.getPontoMensal().size(); i++) {
			if (this.getPontoMensal().get(i).getMes() == pMes
			        && this.getPontoMensal().get(i).getMes() == pAno) {
				nroFaltas = this.getPontoMensal().get(i).getNroFaltas();
			}
		}

		return this.salarioMensal - ((salarioMensal / 30) * nroFaltas);
	}

}
